//
// 待处理工单
//
<template>
  <div class="tenantMenu_main main_container">
    <div class="main_header">
      <div class="padding_container">
        <div class="right">
          <HeaderOperation :parent="this" />
        </div>
      </div>
    </div>
    <div v-loading="loading" class="main_main">
      <SearchBar :parent="this" />
      <div ref="table_container" class="table_container">
        <el-table
          ref="table"
          :data="tableData"
          stripe
          border
          :height="tableHeight"

          :cell-style="cellStyle"
          :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
          @cell-click="cellClick"
          @sort-change="(column)=>{sortChange(column, this)}"
          @selection-change="(val)=>{selectionChange(val, this)}"
        >
          <template slot="empty">
            <div class="empty_content">

              <el-image
                style="width: 120px; height: 100px; margin-left: calc(50% - 65px)"
                :src="imageUrl"
              />
              <div>
                暂无待处理工单
              </div>
            </div>
          </template>
          <!--          <el-table-column type="selection" width="70" align="center" />-->
          <Column
            v-for="(column,index) in tableColumns"
            :key="index"
            :prop="column.prop"
            :is-show="column.isShow"
            :label="column.label"
            :sortable="column.sortable"
            :width="column.width"
            :min-width="column.minWidth"
            :align="column.align"
          />
        </el-table>
      </div>
    </div>
    <div class="main_bottom">
      <pagination
        :total="total"
        :page.sync="pageData.pageNum"
        :limit.sync="pageData.pageSize"
        :selected-num="selectionsAll.length"
        @pagination="getList"
      />
    </div>

  </div>
</template>

<script>
import imageUrl from '@/assets/images/backlogTask/消息暂无数据.jpg'
import { listForSaleCollect, read } from '@/api/backlogTask/backlogTask'
import { mapGetters } from 'vuex'
import ShowDetailOld from '@/views/system/notice/showDetail'
import ShowSystemDetailOld from '@/views/superManage/reportForm/superNotice/showDetail'
export default {
  name: 'ByMaterial',
  computed: {
    ...mapGetters([
      'notificationChangeTag'
    ])
  },
  watch: {
    notificationChangeTag() {
      this.getList()
    }
  },
  data() {
    return {
      imageUrl: imageUrl,
      loading: true,
      pageId: '待处理工单', // 页面唯一标识
      isGetList: '1', // 表示一进页面不需要调list方法
      pageData: {
        pageNum: 1,
        pageSize: 20,
        orderByColumn: 'startTime',
        isAsc: 'desc',
        executeStatus: '0',
        type: '3',
        listType: '3'
      },
      // tableKey: 1,
      total: 1, // 数据一共有多少条
      mainId: 'id', // 表格行ID
      tableHeight: '0', // 表格高度
      tableData: [], // 表格数据
      tableColumns: [], // 表格实际用的字段
      searchColumns: [], // 搜索区实际用的字段
      selections: [], // 表格当前页所选中的行
      selectionsAll: [], // 表格所有页选中的行
      defaultTableColumns: [// 表格常规字段（初始值）
        { prop: 'title', label: '单据类型', canOrder: false },
        { prop: 'businessCode', label: '单据编码', canOrder: false },
        { prop: 'userName', label: '发送人员', canOrder: false },
        { prop: 'startTime', label: '开始时间', sortable: 'custom', canOrder: false }
      ],
      defaultSearchColumns: [// 搜索区常规字段（初始值）
        { prop: 'title', label: '单据类型', type: 'select', optionsName: 'statusOptions' },
        { prop: 'businessCode', label: '单据编码', type: 'input' },
        { prop: 'startTime', label: '开始时间', clearable: true, type: 'time', isTime: true }
      ],
      operationData: [ // 右上角的操作按钮
        { label: '批量审批', perm: '' }
      ],
      statusOptions: [
        { value: undefined, label: '全部' },
        { value: '设备报修', label: '设备报修' },
        { value: '点检任务', label: '点检任务' },
        { value: '保养任务', label: '保养任务' }
      ],
      orderTime: '',
      itenindex: 1
    }
  },
  created() {
  },
  mounted() {
  },
  methods: {
    cellStyle({ row, column }) {
      if (column.property == 'businessCode') {
        return {
          cursor: 'pointer',
          color: '#387bfc'
        }
      }
    },
    cellClick(row, column, cell) {
      if (column.property == 'businessCode') {
        if (row.menuPermission === '0' && row.title != '系统通知' && row.title !== '系统公告' && row.title !== '企业公告') {
          this.$message.warning('您没有当前页面的权限,请联系管理员')
        } else {
          read({ ids: row.id }).then(res => {
            this.$store.state.order.contendId = row.contentId
            this.$router.push('/' + row.menuComponent)
            this.$store.state.order.isStatus = '2'
            this.$parent.$parent.$parent.getInfoMsgNum()
          })
        }
      }
    },
    getList() {
      listForSaleCollect(this.pageData).then(res => {
        this.tableData = res.data
        this.total = res.total
        this.loading = false
        this.$nextTick(() => {
          this.setSelectRow(this)// 设置行选中
          this.tableHeight = this.$refs.table_container.offsetHeight
        })
      })
    },
    getExportData(data) {
      return new Promise(function(resolve, reject) {
        listForSaleCollect(data).then(res => {
          resolve(res.data.dataTable.data)
        })
      })
    }
  }
}
</script>

<style lang="less" scoped>
.main_header{
  .padding_container{
    justify-content: flex-end;
  }
}
</style>
